package com.smartlink.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.smartlink.pojo.Student;
import com.smartlink.pojo.Teacher;

public class LoginDao {
	private SessionFactory sessionFactory;
	private Session session;

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	private Session getSession() {
		session = sessionFactory.getCurrentSession();
		return session;
	}
	
	public Teacher teacherLogin(String number) {
		String hql= "FROM Teacher WHERE jobNumber = ?";
		Teacher teacher = (Teacher) getSession().createQuery(hql).setString(0, number).uniqueResult();
		return teacher;
		
		
	}

	/**
	 * 学生登陆
	 * @param number
	 * @return
	 */
	public Student studentLogin(String number) {
		String hql = "FROM Student WHERE studentId = ?";
		Student student = (Student) getSession().createQuery(hql).setString(0, number).uniqueResult();
		return student;
		
	}
	

	
}
